package cn.wolfcode.wolf2w.util;

import lombok.Getter;

import java.util.Date;

/**
 * 存放redis的key,以及key的有效时间
 */
@Getter
public enum RedisKeys {

    // 短信验证码
    VERIFY_CODE("verify_code",Consts.VERIFY_CODE_VAI_TIME*60L),
    // 攻略的统计数据
    STRATEGY_STATIS("strategy_statis",-1L),
    // 用户收藏的攻略id集合
    USER_STRATEGY_FAVOR("user_strategy_favor",-1L),
    USER_STRATEGY_THUMBSUP("user_strategy_thumbsup",DateUtil.getDateBetween(DateUtil.getEndDate(new Date()),new Date())),
    // token
    TOKEN_CODE("token_code",Consts.USER_INFO_TOKEN_VAI_TIME*60L);

    private String prefix;  // redis key的前缀
    private Long time;      // redis key 的有效时间

    RedisKeys(String prefix,Long time){
        this.prefix = prefix;
        this.time = time;
    }

    // 拼接处完整的redis key
    public String join(String... values){
        StringBuilder sb = new StringBuilder(80);
        sb.append(this.prefix);
        for (String value : values) {
            sb.append(":").append(value);
        }
        return sb.toString();
    }

}
